package javaCode;

/**
 * Created by lxy_920912 on 14/04/2017.
 */
public class LeetCode226 {
    public TreeNode invertTree(TreeNode root) {
        if(root == null || (root.left==null && root.right == null)){
            return root;
        }

        TreeNode p = root.left;
        root.left = root.right;
        root.right = p;
        invertTree(root.left);
        invertTree(root.right);
        return root;
    }
}
